<!DOCTYPE html>
<!--[if IE 7]>    <html class="no-js ie7 ie" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js ie8 ie" lang="en"> <![endif]-->
<!--[if IE 9]>    <html class="no-js ie9 ie" lang="en"> <![endif]-->
<!--[if gt IE 9]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
	<head>
		<meta charset="utf-8" />
		<title>意见反馈_${webName}</title>
		<meta name="description" content="" />
		<meta name="author" content="HuangBQ | ${wwwRoot}" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<#include "../inc/head-common.ftl">
		<#include "../inc/wysiwyg.ftl">
		<style type="text/css">
		  	.tip{color:red}
		</style>
	</head>
	<body>
		<#include "../inc/header.ftl">
		
		<!-- Main content -->
		<div class="container" role="main">
		
			<!-- Breadcrumbs -->
			<ul class="breadcrumb">
				<li><a href="${wwwRoot}"><span class="icon-home"></span> ${wwwName}</a></li>
				<li><a href="${webRoot}">${webName}</a></li>
				<li><a href="${webRoot}feedback/list.do">意见反馈列表</a></li>
				<li class="active">意见反馈处理</li>
			</ul>
			<!-- Breadcrumbs -->
			
			<!-- Main data container -->
			<div class="content">
			
				<!-- Page header -->
				<div class="page-header">
					<h1><span class="icon-plus"></span> 意见反馈处理<small>请善待每个用户的建议</small></h1>
					<ul class="page-header-actions">
						<li class="active"><a href="${webRoot}feedback.do" class="btn btn-wuxia" title="意见反馈" target="_blank"><span class="icon-edit"></span> 意见反馈</a></li>
					</ul>
				</div>
				<!-- /Page header -->
				
				<!-- Page container -->
				<div class="page-container">
				
					<!-- Grid row -->
						<div class="row">

							<article class="span12">
								
								<form class="form-horizontal" id="frmEditFeedback"/>
									<fieldset>
										<div class="control-group">
											<label class="control-label">反馈意见：</label>
											<div class="controls">
											    <p>${fb.advise}</p>
											    <input type="hidden" name="fid" value="${fb.fid}"/>
												<!--p class="help-block">20字内描述你的问题</p-->
											</div>
										</div>
										<div class="control-group">
											<label class="control-label">支持数量：</label>
											<div class="controls">
											    <input type="text" name="supportnum" value="${fb.supportnum}" id="supportnum"/>
												<span class="help-inline"></span>
												<!--p class="help-block">20字内描述你的问题</p-->
											</div>
										</div>
										<div class="control-group">
											<label class="control-label">反对数量：</label>
											<div class="controls">
											    <input type="text" name="againstnum" value="${fb.againstnum}" id="againstnum"/>
												<span class="help-inline"></span>
												<!--p class="help-block">20字内描述你的问题</p-->
											</div>
										</div>
										<div class="control-group">
											<label class="control-label">审核结果：</label>
											<div class="controls">
											    <input type="radio" name="auditstatus" value="0" />待处理
												<input type="radio" name="auditstatus" value="1" />采纳
												<input type="radio" name="auditstatus" value="2" />不采纳
											</div>
										</div>
										<div class="control-group" id="div_auditadvise">
											<label class="control-label">审核意见：</label>
											<div class="controls">
												<textarea id="editor" name="auditadvise" class="wysihtml5" placeholder="审核意见 ..." rows="8">${fb.auditadvise!''}</textarea>
											</div>
										</div>
										<div class="form-actions">
											<button class="btn btn-primary btn-wuxia btn-large" id="editFeedback" type="button">提交审核</button>
										    <input type="reset" value="Reset form!" style="display:none;">
										</div>
									</fieldset>
								</form>
								
							</article>
							
						</div>
						<!-- /Grid row -->
					
				</div>
				<!-- /Page container -->
				
			</div>
			<!-- /Main data container -->
			
		</div>
		<!-- /Main content -->
		
		<#include "../inc/footer.ftl">
		<script>
			$(document).ready(function() {				
				/*初始化审核状态*/
				$("input[name='auditstatus']").each(function(){
                    if($(this).val()=="${fb.auditstatus}"){
                       $(this).attr("checked","checked");
                    }
                });
				if("${fb.auditstatus}"=="0"){
				    $('#div_auditadvise').hide();
				}else{
				    $('#div_auditadvise').show();
				}
                $("input[name='auditstatus']").click(function(){
                    $(this).siblings().attr("checked",false);
                    $(this).attr("checked","checked");
                    if($(this).val()=="0"){
                       $('#div_auditadvise').hide();
                    }else{
                       $('#div_auditadvise').show();
                    }
                });
                
				/*提交表单*/
				$('#supportnum').focus(function(){
				    $(this).next().removeClass("tip").html("");
				});
				$('#againstnum').focus(function(){
				    $(this).next().removeClass("tip").html("");
				});
				$('#editFeedback').click(function(){
				      var flag = checkForm();
				      if(flag==false){
				         $(this).pops({title:'', text:'请将内容填写完整！',type:'error',top:10, left:120, showClose : false,timeout:3000});
				         return false;
				      }
				      var ajax_url = '${webRoot}feedback/update/admin.do';/*表单地址*/
				      var ajax_type = 'POST';/*表单提交类型*/
				      var ajax_data = $("#frmEditFeedback").serialize();/*表单数据*/
				      jQuery.ajax( {  
				           type : ajax_type,  
				           url : ajax_url,  
				           data : ajax_data,  
				           dataType : 'json',  
				           success : function(data) { 
				           	if(data.flag == '1') {
				           		$('#editFeedback').pops({title:'', text:'更新成功！',top:10, left:120, showClose : false,timeout:3000});
				           	} else {
				           		 $('#editFeedback').pops({title:'', text:'更新失败！',type:'error',top:10, left:120, showClose : false,timeout:3000});
				           	}		       
				           },  
				           error : function(data) {  
 
				           }  
				      }); 
				});
				
			});
			/*表单地址*/
			function checkForm(){
			     var flag = true;
			     $('input[name="supportnum"]').each(function(){
                           var supportnum = $.trim($(this).val());
                           if(supportnum==""){
                               flag=false;
                               $(this).next().addClass("tip").html("不能为空");
                           }else{
                              var partten =/^\d+$/;
                              var result = supportnum.match(partten);
                              if(result==null){
                                  flag=false;
                                  $(this).next().addClass("tip").html("请输入正确的数字");
                              }
                           }
                 });
			     $('input[name="againstnum"]').each(function(){
                           var againstnum = $.trim($(this).val());
                           if(againstnum==""){
                               flag=false;
                               $(this).next().addClass("tip").html("不能为空");
                           }else{
                              var partten =/^\d+$/;
                              var result = againstnum.match(partten);
                              if(result==null){
                                  flag=false;
                                  $(this).next().addClass("tip").html("请输入正确的数字");
                              }
                           }
                 });
			     var auditstatus=$('input:radio[name="auditstatus"]:checked').val(); 
			     if(auditstatus!="0"){
			         var auditadvise = $.trim($('#editor').val());
				     if(auditadvise==""){
				         flag = false;
				     }
			     }
			     return flag;
			}
		</script>
		<script src="${scriptRoot}pops.js" type="text/javascript"></script>
</body>
</html>
